'use strict';

const BaseController = require('./base');
const serviceName = 'field';

class FieldController extends BaseController {
  constructor(ctx) {
    super(ctx, serviceName);
  }

  getListQuery(query) {
    const where = {};
    const { college_id, name } = query;

    if (college_id) {
      where.college_id = college_id;
    }
    
    if (name) {
      where.name = {
        [this.app.Sequelize.Op.like]: `%${name}%`
      };
    }

    return where;
  }
}

module.exports = FieldController;
